package com.xlf.common.core.util.page.redis;

import cn.hutool.core.convert.Convert;
import com.xlf.common.core.util.ServletUtils;
import com.xlf.common.core.util.StringUtils;
import com.xlf.common.core.util.spring.SpringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class PageSupport {

    /**
     * 当前记录起始时间戳
     */
    public static final String TIME_STAMP = "timeStamp";

    /**
     * 每页显示记录数
     */
    public static final String PAGE_SIZE = "pageSize";

    /**
     * 偏移量
     */
    public static final String OFF_SET = "offSet";


    /**
     * 排序的方向 "desc" 或者 "asc".
     */
    public static final String IS_ASC = "isAsc";

    /**
     * 封装分页对象
     */
    public static PageDomain getPageDomain()
    {
        PageDomain  pageDomain = new PageDomain();
        pageDomain.setTimeStamp(Convert.toLong(ServletUtils.getParameter(TIME_STAMP), Long.MAX_VALUE));
        pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 5));
        pageDomain.setOffSet(Convert.toInt(ServletUtils.getParameter(OFF_SET), 1));
        pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
        return pageDomain;
    }

    public static PageDomain buildPageRequest()
    {
        return getPageDomain();
    }


    public static void startPage(String key){
        PageDomain pageDomain = buildPageRequest();
        Integer pageSize = pageDomain.getPageSize();
        Integer offSet = pageDomain.getOffSet();
        long timeStamp = pageDomain.getTimeStamp();

    }
}
